package com.utils;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class DOMReader {

	private static String getTagValue(String sTag, Element eElement) {
		NodeList nlList = eElement.getElementsByTagName(sTag).item(0)
				.getChildNodes();
		Node nValue = (Node) nlList.item(0);
		return nValue.getNodeValue();
	}

	public static void main(String[] args) {
		
		String fXmlFile = "http://nds1.nds.nokia.com/uaprof/N2626r100.xml";
		try {

			DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
			DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
			Document doc = dBuilder.parse(fXmlFile);
			doc.getDocumentElement().normalize();

			NodeList nList = doc.getElementsByTagName("prf:JavaPlatform");
			for (int temp = 0; temp < nList.getLength(); temp++) {
				Node nNode = nList.item(temp);
				Element eElement = (Element) nNode;
				NodeList nList1 = eElement.getElementsByTagName("rdf:li");
				if (nList1 != null) {
					for (int temp1 = 0; temp1 < nList1.getLength(); temp1++) {
						Node nNode1 = nList1.item(temp1).getChildNodes().item(0);
						System.out.println("rdf:li == "+nNode1.getNodeValue());
					}
				}
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
